package com.robot.orders.controller;

import com.robot.orders.service.ConfirmationService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * confirmation控制器层
 *
 * @author lin
 */
@RestController
@CrossOrigin
@RequestMapping("/confirmation")
public class ConfirmationController {
    @Autowired
    private ConfirmationService confirmationService;


    /**
     * 查询全部数据
     *
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public Result findAll() {
        return new Result(StatusCode.SUCCESS_QUERY, confirmationService.findAll());
    }

    /**
     * 根据条件查询
     *
     * @param searchMap
     * @return
     */
    @RequestMapping(value = "/search", method = RequestMethod.POST)
    public Result findSearch(@RequestBody Map searchMap) {
        return new Result(StatusCode.SUCCESS_QUERY, confirmationService.findSearch(searchMap));
    }

    /**
     * 删除
     *
     * @param id
     */
    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
    public Result delete(@PathVariable String id) {
        confirmationService.deleteById(id);
        return new Result(StatusCode.SUCCESS_DELETED);
    }
}
